package com.zhl.study.service.chainResponsibility;

/**
 * @description TODO
 * @Author: z156940l@outlook.com
 * @className IHandler
 * @Date: 2024/12/26 21:13
 */
public abstract class IHandler<T, R> {

    public IHandler<T, R> nextHandler;

    public void setNextHandler(IHandler<T, R> nextHandler){
        this.nextHandler = nextHandler;
    }

    public boolean haseNextHandler(){
        return this.nextHandler != null;
    }

    public R handler(T t){
        if (haseNextHandler()){
            return nextHandler.handler(t);
        }
        return null;
    }
}
